---
title: "Lente Ecologica"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(plotly)
library(leaflet)
library(plotly)
iris <- read.csv("~/git/ciencia_colab/data/iris_mod.csv", header = T)
campos <- read.csv("~/git/ciencia_colab/data/campos_gbif_25apr2022.csv", header = T)
NORFLU <- rgdal::readOGR("NORFLU/map.shp")
```
# Início
## Introdução {.sidebar}
{width="200"}
O nome "Lente Ecológica" faz um paralelo entre as metodologias utilizadas no projeto e como a sociedade percebe o meio ambiente. O objetivo geral do projeto é ajustar o 'foco' dos participantes em relação a como estes enxergam a fauna e flora, e como o ser humano se observa nessas relações. Utilizando a observação direta como meio de inserção dos participantes no contexto ambiental através das lentes dos usuários (câmeras e *smartphones*) e meios de comunicação interativos -- as mídias sociais, o projeto buscará incentivar o aprendizado empírico-científico e gerar sensibilização ambiental.
## Row 1 {data-height="650"}
### **Ocorrências de espécies no Norte Fluminense** - Cada ponto na imagem corresponde a um registro de ocorrência de uma espécie ou táxon na região Norte Fluminense. Os dados foram coletados da base *Global Biodiversity Information Facility* (GBIF).
```{r mapa_dori}
pal <- colorFactor(palette = "viridis", domain = unique(campos$kingdom))
NORFLU %>%
leaflet() %>%
addTiles() %>%
addPolygons(col = "",
fillColor = "yellow",
highlight = highlightOptions(weight = 0.5,
color = "red",
fillOpacity = 0.7,
bringToFront = TRUE),
label = ~NM_MUNICIP) %>%
addCircleMarkers(data = campos,
~decimalLongitude,
~decimalLatitude,
radius = 5,
#label = ~as.character(datasetName),
color = ~pal(campos$kingdom),
stroke = FALSE, fillOpacity = 0.5) %>%
addLegend('bottomright',
colors = unique(pal(campos$kingdom)),
labels = unique(campos$kingdom),
title = 'Dataset',
opacity = 0.5)
```
## Row 2 {data-height="250"}
### Box1 {data-width="400"}
```{r}
a2 <- campos %>%
mutate(kingdom = factor(kingdom, levels = c("Viruses", "Bacteria", "Chromista", "Fungi", "Plantae", "Animalia", "incertae sedis"))) %>%
group_by(kingdom) %>%
summarise(spp = n_distinct(scientificName)) %>%
ggplot(aes(y = kingdom, x = spp, fill = kingdom)) +
geom_bar(stat = 'identity') +
theme_classic() +
theme(legend.position = "") +
labs(y = "")
ggplotly(a2) %>%
layout(
showlegend = F,
legend = list(orientation = 'h')
)
```
### Box2
```{r}
rank <- campos %>%
mutate(kingdom = factor(kingdom, levels = c("Viruses", "Bacteria", "Chromista", "Fungi", "Plantae", "Animalia", "incertae sedis"))) %>%
group_by(kingdom, phylum) %>%
summarise(spp = n_distinct(paste(genus, species))) %>%
filter(!phylum %in% c(NA, "")) %>%
arrange(kingdom, spp) %>%
pull(phylum)
a1 <- campos %>%
mutate(kingdom = factor(kingdom, levels = c("Viruses", "Bacteria", "Chromista", "Fungi", "Plantae", "Animalia", "incertae sedis"))) %>%
group_by(kingdom, phylum) %>%
summarise(spp = n_distinct(paste(genus, species))) %>%
filter(!phylum %in% c(NA, "")) %>%
mutate(phylum = factor(phylum, levels = rank)) %>%
ggplot(aes(y = phylum, x = spp, fill = kingdom)) +
geom_bar(stat = 'identity') +
#facet_wrap(kingdom ~ ., scales = 'free', nrow = 1) +
theme_classic() +
theme(legend.position = "") +
labs(x = "Número de táxons", y = "")
ggplotly(a1)
```
### Box3
```{r}
ggplotly(a1)
```
------------------------------------------------------------------------
# Municípios do Norte Fluminense
## Row 1 {data-height="100"}
### Indicador 1
```{r}
ggplotly(a1)
```
### Indicador 2
```{r}
ggplotly(a1)
```
### Indicador 3
```{r}
ggplotly(a1)
```
## Row 2 {data-height="300"}
### Boxplot
```{r}
ggplotly(a1)
```
### Grupos taxonômicos
```{r chart B}
a2 <- iris %>%
pivot_longer(cols = Sepal.Length:Petal.Width, names_to = "variable", values_to = "size") %>%
ggplot(aes(x = variable, y = size, color = Species)) +
geom_boxplot() +
facet_grid(~ Species) +
theme_classic() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(y = "Size (cm)", x = "")
ggplotly(a2)
```
## Row 3 {data-height="300"}
### Temporal
```{r}
linhas <- campos %>%
group_by(year) %>%
summarise(id = n_distinct(occurrenceID),
spp = n_distinct(species)) %>%
mutate(spp_cum = cumsum(spp))
b1 <- linhas %>%
ggplot(aes(y = id, x = year)) +
geom_area(fill = "blue", alpha = 0.6) +
geom_area(data = linhas, aes(y = spp), fill = "red", alpha = 0.6) +
theme_classic() +
theme(legend.position = "") +
labs(x = "Anos", y = "Espécies registradas (n)") +
scale_x_continuous(breaks = seq(1800, 2022, by = 20))
ggplotly(b1)
```
### Locais de amostragem (Península de Gaspe)
```{r chart C}
# conferir no mapa
iris %>%
leaflet() %>%
addTiles() %>%
addMarkers(~lon,
~lat)
```